package dao;

import java.util.List;

import modelo.Telefonosalon;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import util.HibernateUtil;

public class TelefonoSalonDao{
	
	private Session session;
	SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
	
	public TelefonoSalonDao() {
		super();
	}
	
	public List<Telefonosalon> obtenerTelefonosSalon() {
		session=sessionFactory.openSession();
		
		Query query = session.createQuery("SELECT t FROM Telefonosalon t");
		List<Telefonosalon> t = query.list();
		
		session.close();
		
		return t;
	}

	public void guardarTelefonoSalon(Telefonosalon tel) {
		session = sessionFactory.openSession();
		session.beginTransaction();
		session.saveOrUpdate(tel);
		session.getTransaction().commit();
		session.close();
	}

}
